package spring.cloud.tasks.tasks_assign_manager.task_item_assign.pick_up;

import org.apache.curator.framework.CuratorFramework;
import spring.cloud.tasks.common.task_item_allot.OnlineExecutor;
import spring.cloud.tasks.common.task_item_allot.TaskItem;
import spring.cloud.tasks.tasks_assign_manager.service.TaskItemAssignService;
import spring.cloud.tasks.tasks_assign_manager.task_item_assign.PreferExecutorSettings;

import java.util.List;

public abstract class PickUp {
    protected TaskItemAssignService taskItemAssignService;

    public PickUp(TaskItemAssignService taskItemAssignService) {
        this.taskItemAssignService = taskItemAssignService;
    }

    protected void log() {

    }

    /**
     * 摘取
     *
     * @param taskIdList                   该域下所有任务
     * @param enableTaskIdList             该域下所有启用的任务
     * @param pickUpEdTaskItemList         摘取可进行再分配的任务项
     * @param discardTaskItemList          摘取不可进行再分配的任务项
     * @param onlineExecutorList           在线的执行器
     * @param ownTrafficOnlineExecutorList 拥有流量的在线的执行器,注意#onlineExecutorList和ownTrafficOnlineExecutorList的Executor是同一个对象
     * @return true摘取成功；false摘取失败
     */
    public abstract boolean pickUp(CuratorFramework curatorFramework,//
                                   List<String> taskIdList,//
                                   List<String> enableTaskIdList,//
                                   List<TaskItem> pickUpEdTaskItemList,//
                                   List<TaskItem> discardTaskItemList,//
                                   List<OnlineExecutor> onlineExecutorList,//
                                   List<OnlineExecutor> ownTrafficOnlineExecutorList,//
                                   PreferExecutorSettings preferExecutorSettings
    ) throws Exception;


}
